//
//  URLStore.m
//  TwitterFon
//
//  Created by koolearn on 11-4-13.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "URLStore.h"

static URLStore* sharedInstance;

@implementation URLStore

+ (URLStore*) sharedInstance
{
	@synchronized(self) {
		if ( sharedInstance == nil ) {
			sharedInstance = [[URLStore alloc] init];
		}
		return sharedInstance;
	}
}


- (NSString*) urlForKey:(NSString*) key format:(NSString*)format
{
	NSString* url = nil;
	if ( [key compare:kAPIMethodVerify] == NSOrderedSame ) url = @"/users/veri_credentials";
	if ( [key compare:kAPIMethodFriendsTimeline] == NSOrderedSame ) url = @"/weibo/home_timeline";
	if ( [key compare:kAPIMethodUserProfile] == NSOrderedSame ) url = @"/users/show";
	if ( [key compare:kAPIMethodUserTimeline] == NSOrderedSame ) url = @"/weibo/user_timeline";
	if ( [key compare:kAPIMethodMentions] == NSOrderedSame ) url = @"/weibo/mentions";
	if ( [key compare:kAPIMethodPostTweet] == NSOrderedSame ) url = @"/weibo/update";
	if ( [key compare:kAPIMethodDestroyTweet] == NSOrderedSame ) url = @"/weibo/destroy";
    if ( [key compare:kAPIMethodTweetUpload] == NSOrderedSame ) url = @"/weibo/upload";
	if ( [key compare:kAPIMethodFavoriteCreate] == NSOrderedSame ) url = @"/favorites/create";
	if ( [key compare:kAPIMethodFavoriteDestroy] == NSOrderedSame ) url = @"/favorites/destroy_batch";
	if ( [key compare:kAPIMethodFavoriteList] == NSOrderedSame ) url = @"/favorites/list";
    
	if ( [key compare:kAPIMethodMessageConversation] == NSOrderedSame ) url = @"/private_letter/msgsaylist";
	if ( [key compare:kAPIMethodMessageSend] == NSOrderedSame ) url = @"/private_letter/msgnew";
	if ( [key compare:kAPIMethodMessageSendToGroup] == NSOrderedSame ) url = @"/private_letter/groupMsgNew";
	if ( [key compare:kAPIMethodGroupUsers] == NSOrderedSame ) url = @"/friendships/group_friends";
	if ( [key compare:kAPIMethodMessageRelation] == NSOrderedSame ) url = @"/private_letter/msgrela";
	
	if ( [key compare:kAPIMethodFriendShipFollowers] == NSOrderedSame ) url = @"/friendships/followers";
	if ( [key compare:kAPIMethodFriendShipFollowing] == NSOrderedSame ) url = @"/friendships/friends";
	if ( [key compare:kAPIMethodFriendShipCreate] == NSOrderedSame ) url = @"/friendships/create";
	if ( [key compare:kAPIMethodFriendShipDestroy] == NSOrderedSame ) url = @"/friendships/destroy";
	if ( [key compare:kAPIMethodFriendShipSetUserGroup] == NSOrderedSame ) url = @"/friendships/updaterelxgroup";
	
	if ( [key compare:kAPIMethodGroupGetGroups] == NSOrderedSame ) url = @"/group/groups";
	if ( [key compare:kAPIMethodGroupCreate] == NSOrderedSame ) url = @"/group/create";
	if ( [key compare:kAPIMethodGroupDestroy] == NSOrderedSame ) url = @"/group/destory";
	if ( [key compare:kAPIMethodGroupUpdate] == NSOrderedSame ) url = @"/group/update";
    
    //微博
    if ( [key compare:kAPIMethodTweetShow] == NSOrderedSame ) url = @"/weibo/show";
    if ( [key compare:kAPIMethodTweetRepost] == NSOrderedSame ) url = @"/weibo/repost";
    if ( [key compare:kAPIMehtodTweetRetweetUsers] == NSOrderedSame ) url = @"/weibo/forward_users";
    
    //评论
    if ( [key compare:kAPIMethodRemarkList] == NSOrderedSame ) url = @"/remark/list";
    if ( [key compare:kAPIMethodRemarkCreate] == NSOrderedSame ) url = @"/remark/createnew";
    
    //默默关注
    if ( [key compare:kAPIMethodSilenceFollowing] == NSOrderedSame ) url = @"/favusers/list";
    if ( [key compare:kAPIMethodCreateSilenceFollowing] == NSOrderedSame ) url = @"/favusers/create";
    if ( [key compare:kAPIMethodDestroySilenceFollowing] == NSOrderedSame ) url = @"/favusers/destroy";
    
    //名片
    if ( [key compare:kAPIMethodCardMyCards] == NSOrderedSame ) url = @"/card/userCards";
    if ( [key compare:kAPIMethodCardFriendCards] == NSOrderedSame ) url = @"/card/friendCard";
    if ( [key compare:kAPIMethodCardCreateCard] == NSOrderedSame ) url = @"/card/addCard";
    if ( [key compare:kAPIMethodCardDestroyCard] == NSOrderedSame ) url = @"/card/destroyMyCard";
    if ( [key compare:kAPIMethodCardAskCard] == NSOrderedSame ) url = @"/card/ask";
    if ( [key compare:kAPIMethodCardAskCardAccept] == NSOrderedSame ) url = @"/card/agreeAskCard";
    if ( [key compare:kAPIMethodCardAskCardReject] == NSOrderedSame ) url = @"/card/rejectAskCard";
    
    //注册
    if ( [key compare:kAPIMethodRegisterRegister] == NSOrderedSame ) url = @"/regist/regist";
    if ( [key compare:kAPIMethodRegisterActivate] == NSOrderedSame ) url = @"/regist/active";
	
	if ( [key compare:kAPIMethodSearchUser] == NSOrderedSame ) url = @"/search/users";
	
    //数据同步
	if ( [key compare:kAPIMethodDataup] == NSOrderedSame ) url = @"/data/up";
    if ( [key compare:kAPIMethodUpload] == NSOrderedSame ) url = @"/upload/upload";
	
	if ( url == nil ) return nil;
	
	return [NSString stringWithFormat:@"%@%@.%@", kAPIUrl, url, format];
}


- (void) dealloc
{
	[super dealloc];
}

@end
